*** One-Child Policy, Marriage Distortion, and Welfare Loss ***
*** by Wei Huang, Yinghao Pan and Yi Zhou ***

clear all 
set more off
set scheme s1mono
cap log close 
graph set window fontface "Times New Roman"

set niceness 10
gl MAIN = "F:\Dropbox"

gl path1 = "$MAIN/Census"
gl path2 = "$MAIN/Marriage/Working_data"
gl path3 = "$MAIN/Marriage/Restat/dataverse_files/Results" 
gl path4 = "$MAIN/Marriage/Restat/dataverse_files/Graphics" 


**** Appendix Table A8 ****


use "$path2/fuzzydid_unmarr", clear 



fcollapse unmarried HM  (sum) n, by(prov_hk urban_hk mino_policy wave year_birth han sex)
gen age = wave - year_birth

merge m:1 prov_hk han year_birth using "$path2/fuzzydid_group", nogen


 replace n = n* 10 if han == 0 
gen rep = round(n/100)
gen iid = _n 
expand 300
replace rep = rep+1 
bys iid: gen inn = _n 
keep if inn <= rep
drop inn iid 


egen sexXage = group(sex age)

set seed 200
foreach eth in  "han == 1""han ==0" {
foreach pref in "1" "mino_policy == 1" "mino_policy == 0"{
 fuzzydid unmarried G_T G_Tplus1 year_birth fine_16_25 if `eth' & `pref',  ///
 did   qualitative(prov_hk wave)  newcateg(0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5) 

} 
}





use "$path2/fuzzy_did_hm", clear 



fcollapse HM  (sum) n, by(prov_hk urban_hk mino_policy wave year_birth han sex)
gen age = wave - year_birth 

merge m:1 prov_hk han year_birth using "$path2/fuzzydid_group_hm", nogen



replace n = n* 10 if han == 0 
gen rep = round(n/40)
gen iid = _n 
expand 325
replace rep = rep+1 
bys iid: gen inn = _n 
keep if inn <= rep
drop inn iid 

egen sex_age = group(sex age)
set seed 200

foreach eth in "han == 1"  "han ==0" {
foreach pref in "1" "mino_policy == 1" "mino_policy == 0"{
 fuzzydid HM G_T G_Tplus1 year_birth fine_16_25 if `eth' & `pref',  did   qualitative(prov_hk wave )  newcateg(0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5)  

} 
}

 